{
 "cells": [
  {
   "cell_type": "raw",
   "metadata": {
    "raw_mimetype": "text/restructuredtext"
   },
   "source": [
    ".. _nb_scatter:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Scatter Plot\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The traditional scatter plot is mostly used for lower dimensional objective spaces."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Scatter 2D"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "from pymoo.visualization.scatter import Scatter\n",
    "from pymoo.problems import get_problem\n",
    "\n",
    "F = get_problem(\"zdt3\").pareto_front()\n",
    "Scatter().add(F).show()"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "The plot can be further customized by supplying a title, labels, and by using the plotting directives from matplotlib. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "F = get_problem(\"zdt3\").pareto_front(use_cache=False, flatten=False)\n",
    "plot = Scatter()\n",
    "plot.add(F, s=30, facecolors='none', edgecolors='r')\n",
    "plot.add(F, plot_type=\"line\", color=\"black\", linewidth=2)\n",
    "plot.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Scatter 3D"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "from pymoo.util.ref_dirs import get_reference_directions\n",
    "\n",
    "ref_dirs = get_reference_directions(\"uniform\", 3, n_partitions=12)\n",
    "\n",
    "F = get_problem(\"dtlz1\").pareto_front(ref_dirs)\n",
    "\n",
    "plot = Scatter()\n",
    "plot.add(F)\n",
    "plot.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Scatter ND / Pairwise Scatter Plots"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "F = np.random.random((30, 4))\n",
    "\n",
    "plot = Scatter(tight_layout=True)\n",
    "plot.add(F, s=10)\n",
    "plot.add(F[10], s=30, color=\"red\")\n",
    "plot.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### API"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {
    "raw_mimetype": "text/restructuredtext"
   },
   "source": [
    ".. autoclass:: pymoo.visualization.scatter.Scatter\n",
    "    :noindex:"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
